
#ifndef __USER_DEF_
#define __USER_DEF_
#include <stdint.h>

#define ARRAY_SZ(a) (sizeof(a) / sizeof(a[0]))
#define Min(a, b) (((a) < (b)) ? (a) : (b))
#define Max(a, b) (((a) > (b)) ? (a) : (b))
#define PI 3.1415926535897932384626433832795
#define KB 1024u
#define MB (1024u * KB)
#define HZ 1u
#define KHZ 1000u
#define MHZ 1000000u
#define EPSILON 0.000001
#define TRUE 1
#define FALSE 0
#define __WEAK __weak

extern volatile uint32_t ul_tick_500us;
#define get_ticks() (ul_tick_500us)

#if defined(DB_PRINT)
extern int printf(const char *format, ...);
#define db_prinf(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define trace_printf(fmt, ...)                                                 \
  printf("%s:%d:trace: " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#else
#define db_prinf(fmt, ...)
#define trace_printf(fmt, ...)
#endif

#endif
